외부 평가 | 자카드계수 평가 |
분류모형 평가 방법을 응용 | |
내부 평가 | 단순계산법 |
군집 간의 거리를 계산하여 평가 | |
엘보 메소드 |
> items<-c('chicken', 'coke', 'cider')
> count<-sample(3, 100, replace=T)
> transactionId<-c()
> transactionItem<-c()
> for(i in 1:100){
+ current_transaction<-sample(items, count[i])
+ for(j in 1: length(current_transaction)){
+ transactionId<-c(transactionId, i)
+ transactionItem<-c(transactionItem, current_transaction[j])
+ }
+ }
>
> transaction<-data.frame(transactionId, transactionItem)
> head(transaction, 4)
transactionId transactionItem
1 1 chicken
2 2 cider
3 2 chicken
4 2 coke
> library(arules)
Loading required package: Matrix
Attaching package: ‘arules’
The following objects are masked from ‘package:base’:
abbreviate, write
> transactionById<-split(transaction$transactionItem, transaction$transactionId)
> transactionById_processed<-as(transactionById, 'transactions’)
# 연관분석 실시
# parameter를 활용하여 최소 지지도(supp)와 최소 신뢰도(conf)값 설정(default value supp=0.1, conf=0.8)
> result<-apriori(transactionById_processed, parameter=list(supp=0.2, conf=0.7))
> result
set of 10 rules
> inspect(result)
lhs rhs support confidence coverage lift count
[1] {} => {chicken} 0.76 0.7600000 1.00 1.0000000 76
[2] {} => {coke} 0.74 0.7400000 1.00 1.0000000 74
[3] {cider} => {chicken} 0.53 0.7681159 0.69 1.0106789 53
[4] {cider} => {coke} 0.55 0.7971014 0.69 1.0771641 55
[5] {coke} => {cider} 0.55 0.7432432 0.74 1.0771641 55
[6] {chicken} => {coke} 0.54 0.7105263 0.76 0.9601707 54
[7] {coke} => {chicken} 0.54 0.7297297 0.74 0.9601707 54
[8] {chicken,cider} => {coke} 0.43 0.8113208 0.53 1.0963794 43
[9] {cider,coke} => {chicken} 0.43 0.7818182 0.55 1.0287081 43
[10] {chicken,coke} => {cider} 0.43 0.7962963 0.54 1.1540526 43